package com.ayoka.parenting.ui.meditation.question;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.ayoka.parenting.R;
import com.jincp.common.dialog.BaseDialogBuilder;
import com.jincp.common.dialog.BaseDialogFragment;
import com.jincp.common.utils.StringUtil;

/**
 * =========================================================
 *
 * @ProjectName:
 * @ClassName: WhiteBoardDialog
 * @Description:
 * @Author: jincp
 * @CreateDate: 2019/9/19 16:18
 * =========================================================
 */
public class MeditationCompletedDialog extends BaseDialogFragment {

    public static MeditationCompletedDialog newInstance(Builder builder) {
        MeditationCompletedDialog dialog = new MeditationCompletedDialog();
        Bundle bundle = getArgumentBundle(builder);
        bundle.putInt("DayNumber", builder.dayNumber);
        dialog.setArguments(bundle);
        return dialog;
    }


    @Override
    protected void convertView(@Nullable final View container, final BaseDialogFragment dialogFragment) {
        //返回
        container.findViewById(R.id.iv_close).setOnClickListener(new CloseClickListener());
        container.findViewById(R.id.btn_complete).setOnClickListener(new CloseClickListener());

        TextView tvDayNumber = container.findViewById(R.id.tv_day_number);
        if (getArguments() != null) {
            int dayNumber = getArguments().getInt("DayNumber");
            tvDayNumber.setText(StringUtil.formatString("第%d天", dayNumber));
        }
    }


    @Override
    protected int getLayoutId() {
        return R.layout.dialog_meditation_completed;
    }


    public static class Builder extends BaseDialogBuilder<Builder, MeditationCompletedDialog> {

        private int dayNumber;

        public Builder setDayNumber(int dayNumber) {
            this.dayNumber = dayNumber;
            return this;
        }

        @Override
        public MeditationCompletedDialog build() {
            return MeditationCompletedDialog.newInstance(this);
        }
    }
}